<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Category_Controller extends CI_Controller {

    function __construct() {
        parent::__construct();
    }
    public $table = 'tbl_category';

    public function index() {
        $this->view();
    }

    # to view data
    public function view() {
        $data["title"] = "Category";
        $data['data_list'] = $this->selectModel->selectData($this->table);
        $this->load->view('panel/category/category/list', $data);
    }

    # to add data
    public function add() {
        $data["title"] = "Category";
        # code...get_main_category
        $table = "tbl_main_category";
        $data['main_category_list'] = $this->selectModel->selectData($table);
        if(isset($_POST['save'])){
            $MainCategory = 1; //$_POST["MainCategory"];
            $Title = $_POST['Title'];
            $fields = array("CategoryTitle", "MainCategoryID", "Enable");
            $values = array($Title, $MainCategory, 1);
            $data['data_add'] = $this->addModel->addData($this->table, $fields, $values);
        }
        $this->load->view('panel/category/category/add', $data);
    }

    # to update data
    public function update() {
        $data["title"] = "Category";
        if(isset($_POST['update'])){
            $Title = $_POST['Title'];
            $fields = array("MainCategoryTitle");
            $values = array($Title);
            $data['data_add'] = $this->addModel->addData($this->table, $fields, $values);
        }
        $this->load->view('panel/category/category/edit', $data);
    }

    # to delete data
    public function delete() {
        #code here
    }
}

/* End of file category_controller.php */
/* Location: ./application/controllers/panel/category_controller.php */